package com.zone.session;

import com.zone.binding.MapperRegistry;
import com.zone.mapping.MappedStatement;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: zongzi
 * @description: TODO
 * @date: 2023/12/4
 */
public class Configuration {


    private final MapperRegistry mapperRegistry = new MapperRegistry();

    private final Map<String, MappedStatement> registryMappingStatement = new HashMap<>();


    public void addStatement(MappedStatement mappedStatement) {
        String key = String.format("%s.%s", mappedStatement.getNamespace(), mappedStatement.getId());
        registryMappingStatement.put(key, mappedStatement);
    }

    public <T> T getMapper(Class<T> clazz, SqlSession sqlSession) {
        return mapperRegistry.getMapper(clazz, sqlSession);
    }

    public void addMapper(Class<?> clazz) {
        mapperRegistry.addMapper(clazz);
    }
}
